package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaCharityActivitiesEnroll;
import com.ruoyi.system.service.IJiajiaCharityActivitiesEnrollService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公益活动报名Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@Controller
@RequestMapping("/jiajia/jiajiaCharityActivitiesEnroll")
public class JiajiaCharityActivitiesEnrollController extends BaseController
{
    private String prefix = "jiajia/jiajiaCharityActivitiesEnroll";

    @Autowired
    private IJiajiaCharityActivitiesEnrollService jiajiaCharityActivitiesEnrollService;

    @RequiresPermissions("jiajia:jiajiaCharityActivitiesEnroll:view")
    @GetMapping()
    public String jiajiaCharityActivitiesEnroll()
    {
        return prefix + "/jiajiaCharityActivitiesEnroll";
    }

    /**
     * 查询公益活动报名列表
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivitiesEnroll:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll)
    {
        startPage();
        List<JiajiaCharityActivitiesEnroll> list = jiajiaCharityActivitiesEnrollService.selectJiajiaCharityActivitiesEnrollList(jiajiaCharityActivitiesEnroll);
        return getDataTable(list);
    }

    /**
     * 导出公益活动报名列表
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivitiesEnroll:export")
    @Log(title = "公益活动报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll)
    {
        List<JiajiaCharityActivitiesEnroll> list = jiajiaCharityActivitiesEnrollService.selectJiajiaCharityActivitiesEnrollList(jiajiaCharityActivitiesEnroll);
        ExcelUtil<JiajiaCharityActivitiesEnroll> util = new ExcelUtil<JiajiaCharityActivitiesEnroll>(JiajiaCharityActivitiesEnroll.class);
        return util.exportExcel(list, "公益活动报名数据");
    }

    /**
     * 新增公益活动报名
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存公益活动报名
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivitiesEnroll:add")
    @Log(title = "公益活动报名", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll)
    {
        return toAjax(jiajiaCharityActivitiesEnrollService.insertJiajiaCharityActivitiesEnroll(jiajiaCharityActivitiesEnroll));
    }

    /**
     * 修改公益活动报名
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll = jiajiaCharityActivitiesEnrollService.selectJiajiaCharityActivitiesEnrollById(id);
        mmap.put("jiajiaCharityActivitiesEnroll", jiajiaCharityActivitiesEnroll);
        return prefix + "/edit";
    }

    /**
     * 修改保存公益活动报名
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivitiesEnroll:edit")
    @Log(title = "公益活动报名", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll)
    {
        return toAjax(jiajiaCharityActivitiesEnrollService.updateJiajiaCharityActivitiesEnroll(jiajiaCharityActivitiesEnroll));
    }

    /**
     * 删除公益活动报名
     */
    @RequiresPermissions("jiajia:jiajiaCharityActivitiesEnroll:remove")
    @Log(title = "公益活动报名", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaCharityActivitiesEnrollService.deleteJiajiaCharityActivitiesEnrollByIds(ids));
    }

    /**
     * 审核
     * @param jiajiaCharityActivitiesEnroll
     * @return
     */
    @Log(title = "公益活动报名", businessType = BusinessType.UPDATE)
    @PostMapping("/audit")
    @ResponseBody
    public AjaxResult audit(JiajiaCharityActivitiesEnroll jiajiaCharityActivitiesEnroll){
        return toAjax(jiajiaCharityActivitiesEnrollService.auditJiajiaCharityActivitiesEnroll(jiajiaCharityActivitiesEnroll));
    }
}
